use "$dataDir/dataset_fires_harvest_daily_weather", clear
		
	merge m:1 id_mun using "$dataDir/dataset_socioec_ind_municipality", gen(merge2)

	keep if merge2==3
	
	egen mean_pob=mean(pobreza)
	gen more_pov=pobreza>mean_pob

	egen mean_pob_e=median(pobreza_e)
	gen more_pov_ex=pobreza_e>mean_pob_e

	
	egen mean_salud=median(ic_asalud)
	gen less_salud=ic_asalud<mean_salud
	
	egen mean_ed=median(ic_rezedu)
	gen less_ed=ic_rezedu>mean_ed

*Table: poverty
		local depvar "shf"
		local cluslvl "id_mills"

	foreach var in `depvar'{
	reghdfe `var' afterXtreatment temp_celsius rain rain2, abs(id_mills i.year#i.month) vce(cluster `cluslvl')
		estimates store `var'_treat_did_nohet
		estadd ysumm, mean
		estadd local moyearfe "Yes"
		estadd local millfe "Yes"	
		estadd local cluslvl "Mill"
		estadd local wc "Yes"
		estadd local sample "All"

	forvalues i=0/1{	
	reghdfe `var' afterXtreatment temp_celsius rain rain2  if more_pov==`i', abs(id_mills i.year#i.month) vce(cluster `cluslvl')
		estimates store `var'_treat_did_het`i'
		estadd ysumm, mean
		estadd local moyearfe "Yes"
		estadd local millfe "Yes"	
		estadd local cluslvl "Mill"
		estadd local wc "Yes"
		if `i'==0{
			estadd local sample "Lower"
		}
		if `i'==1{
			estadd local sample "Higher"
		}


	}		
	esttab `var'_treat_did_nohet `var'_treat_did_het0 `var'_treat_did_het1   using "$mainDir/tables/TabA6_poverty_heterogeneity.tex", replace b(%12.5fc) se(%12.5fc) keep(afterXtreatment) varlabels(afterXtreatment  "After 2015 $\times$ Regulated")  label starl(* 0.1 ** 0.05 *** 0.01) stats(ymean N r2 moyearfe millfe  wc cluslvl sample, fmt(%12.3fc %12.0fc %12.3fc)  label("Mean" "Obs." "R-squared" "Month by Year FE" "Mill FE" "Weather controls" "Cluster level" "Poverty level (wrt median)")) nonotes
	}
	
